<template>
    <div>
        <table>
            <tr>
                <td>项目名称</td>
                <td>
                    <input type="text" v-model="data.xmmc">
                </td>
            </tr>
            <tr>
                <td>启用/禁用</td>
                <td>
                    <input type="text" v-model="data.zt">
                </td>
            </tr>
            <tr>
                <td>状态</td>
                <td>
                    <input type="text" v-model="data.sc">
                </td>
            </tr>
            <tr>
                <td>项目编号</td>
                <td>
                    <input type="text" v-model="data.kfbh">
                </td>
            </tr>
            <tr>
                <td>服务人数</td>
                <td>
                    <input type="text" v-model="data.fwrs">
                </td>
            </tr>
            <tr>
                <td>服务时长</td>
                <td>
                    <input type="text" v-model="data.fwsc">
                </td>
            </tr>
            <tr>
                <td>佣金</td>
                <td>
                    <input type="text" v-model="data.yj">
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="button" value="添加" @click="add">
                </td>
            </tr>
        </table>

    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';

const data=ref({
    "xmid": 0,
  "kfbh": "string",
  "xmmc": "string",
  "zt": true,
  "sc": true,
  "fwrs": 0,
  "fwsc": 0,
  "yj": 0
})
const add=()=>{
        if(data.value.xmmc==""){
            alert("项目名称不能为空")
            return
        }
        if(data.value.yj==0){
            alert("佣金不能为空")
            return
        }
        if(data.value.fwrs==0){
            alert("服务人数不能为空")
            return
        }
        if(data.value.fwsc==0){
            alert("服务时长不能为空")
            return
        }

   
    axios.post("https://localhost:7189/api/kf/add",data.value).then(res=>{
        if(res.data>0){
            alert("添加成功");
            location.href="/xss"
        }else{
            alert("添加失败")
        }
    })
}



</script>

<style scoped>

</style>